<?php

//defined('BASEPATH') OR exit('No direct script access allowed');



class Index extends CI_Controller{


    public function __construct()
    {
        parent::__construct();
      //  $this->load->database();
    }

    public function indexs()
    {

        $query = $this->db->query('SELECT  * FROM  my_goods ');
        $all=$query->result_array();
        $row=$query->row_array(2);
        p($all);
        p($row);
        die;


        $this->load->view('welcome_message');
    }

    //标准插入
    public function add()
    {

        $title="'sdfsdf#";
        $img="aa/a.png";
        $sql="insert into my_lunbo(`title`,`img`)values(".$this->db->escape($title).",".$this->db->escape($img).")";

        p($sql);
        $sql=$this->db->insert_string('my_lunbo',array('title'=>$title,'img'=>$img));
        p($sql);
        $sql=$this->db->select('title,img,sort,id')->from('my_lunbo')->where('id=5')->get()->result();
        p($sql);

    }

    //查询构造器
    public function get()
    {
        $data = array(
            'title' => "'aaa",
            'img' => 'a.png',
            'sort' => 20
        );


        $res=$this->db->insert('my_lunbo', $data);
        p($res);

    }


}